{
Author:  Prof1983 prof1983@yandex.ru
Created: 14.03.2009
LastMod: 14.03.2009
}
unit AUIclDBGrid;

interface

uses
  DBGrids, ABase, AUI, AUIcl;

type
  TAUIclDBGrid = class(TInterfacedObject, IAUIclDBGrid, IAUIWidget)
  private
    FControl: TDBGrid;
    FUI: IAUserInterface;
  public // IAUIWidget
    function GetRequestSize: TAUISize;
    procedure SetAllocateSize(Width, Height: Integer);
    procedure SetPosition(ALeft, ATop: Integer);
    procedure SetRequestSize(Width, Height: Integer);
  public // IAUIContainer
    procedure AddWidget(Widget: IAUIWidget);
  protected // IAUIControl
    function GetEnabled: ABoolean;
    function GetHint: AString;
    function GetName: AString;
    function GetText: AString;
    function GetVisible: ABoolean;
    procedure SetEnabled(Value: ABoolean);
    procedure SetHint(const Value: AString);
    procedure SetName(const Value: AString);
    procedure SetText(const Value: AString);
    procedure SetVisible(Value: ABoolean);
  public
    constructor Create(UI: IAUserInterface; Control: TDBGrid);
    class function New(UI: IAUserInterface): TAUIclDBGrid;
  end;

implementation

{ TAUIclDBGrid }

procedure TAUIclDBGrid.AddWidget(Widget: IAUIWidget);
begin
end;

constructor TAUIclDBGrid.Create(UI: IAUserInterface; Control: TDBGrid);
begin
  inherited Create;
  FControl := Control;
  FUI := UI;
  FUI.RegisterWidgetControl(Self, Control);
end;

function TAUIclDBGrid.GetEnabled: ABoolean;
begin
  Result := FControl.Enabled;
end;

function TAUIclDBGrid.GetHint: AString;
begin
  Result := FControl.Hint;
end;

function TAUIclDBGrid.GetName: AString;
begin
  Result := FControl.Name;
end;

function TAUIclDBGrid.GetRequestSize: TAUISize;
begin
  Result.Width := 0;
  Result.Height := 0;
end;

function TAUIclDBGrid.GetText: AString;
begin
  Result := FControl.Name;
end;

function TAUIclDBGrid.GetVisible: ABoolean;
begin
  Result := FControl.Visible;
end;

class function TAUIclDBGrid.New(UI: IAUserInterface): TAUIclDBGrid;
begin
  Result := TAUIclDBGrid.Create(UI, TDBGrid.Create(nil));
end;

procedure TAUIclDBGrid.SetAllocateSize(Width, Height: Integer);
begin
end;

procedure TAUIclDBGrid.SetEnabled(Value: ABoolean);
begin
  FControl.Enabled := Value;
end;

procedure TAUIclDBGrid.SetHint(const Value: AString);
begin
  FControl.Hint := Value;
end;

procedure TAUIclDBGrid.SetName(const Value: AString);
begin
  FControl.Name := Value;
end;

procedure TAUIclDBGrid.SetPosition(ALeft, ATop: Integer);
begin
  FControl.Left := ALeft;
  FControl.Top := ATop;
end;

procedure TAUIclDBGrid.SetRequestSize(Width, Height: Integer);
begin
end;

procedure TAUIclDBGrid.SetText(const Value: AString);
begin
end;

procedure TAUIclDBGrid.SetVisible(Value: ABoolean);
begin
  FControl.Visible := Value;
end;

end.
